<?php

namespace Fize\Third\WechatWork\Qyapi;

use Fize\Third\WechatWork\QyapiAbstract;

/**
 * 身份验证
 */
class Auth extends QyapiAbstract
{

    /**
     * 获取访问用户身份
     * @param string $code 授权获取到的code
     * @return array
     * @see https://developer.work.weixin.qq.com/document/path/91023
     */
    public function getuserinfo(string $code): array
    {
        return $this->httpGet("/auth/getuserinfo?access_token={$this->accessToken}&code={$code}");
    }

    /**
     * 获取访问用户敏感信息
     * @param string $user_ticket 成员票据
     * @return array
     * @see https://developer.work.weixin.qq.com/document/path/95833
     */
    public function getuserdetail(string $user_ticket): array
    {
        $params = [
            'user_ticket' => $user_ticket
        ];
        return $this->httpPost("/auth/getuserdetail?access_token={$this->accessToken}", $params);
    }

    /**
     * 获取用户二次验证信息
     * @param string $code 用户进入二次验证页面时，企业微信颁发的code
     * @return array
     * @see https://developer.work.weixin.qq.com/document/path/99499
     */
    public function getTfaInfo(string $code): array
    {
        $params = [
            'code' => $code
        ];
        return $this->httpPost("/auth/get_tfa_info?access_token={$this->accessToken}", $params);
    }
}